package test;
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.Date;
public class SessionProperty extends HttpServlet{
	@Override
	protected void doPost(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException{
		HttpSession session=request.getSession();
		response.setHeader("Cache-Control", "no-cache");
		response.setContentType("text/html;charset=gbk");
		PrintWriter out=response.getWriter();
		out.println("<html>");
		out.println("<head>");
		out.println("<title>会话属性<title>");
		out.println("</head>");
		out.println("<body>");
		out.println("<p>会话ID：");
		out.println(session.getId());
		out.println("</p>");
		out.println("<p>会话创建时间");
		out.println(new Date(session.getCreationTime()));
		out.println("</p>");
		out.println("<p>最近访问时间：");
		out.println(new Date(session.getLastAccessedTime()));
		out.println("</p>");
		out.println("<p>会话失效时长：");
		out.println(new Date(session.getMaxInactiveInterval()));
		out.println("秒</p>");
		out.println("</body>");
		out.println("</html>");
	}
	@Override
	protected void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException,IOException{
		doPost(request,response);
	}
}
